package com.hqq;

import com.hqq.entity.Customer;
import com.hqq.util.DBUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * CustomerService
 * Created by heqianqian on 2017/7/22.
 */
public class CustomerService {

    /**
     * 获取用户列表
     */
    public List<Customer> getCustomerList() {
        String sql = "SELECT * FROM customer";
        return DBUtil.queryEntityList(Customer.class, sql);
    }

    /**
     * 更新用户
     */
    public boolean updateCustomer(Customer customer) {
        Map<String, Object> map = new HashMap<>();
        map.put("id", customer.getId());
        map.put("name", customer.getName());
        map.put("contact", customer.getContact());
        map.put("telephone", customer.getTelephone());
        map.put("email", customer.getEmail());
        map.put("remark", customer.getRemark());
        return DBUtil.updateEntity(customer.getClass(), customer.getId(), map);
    }

}
